package exc;
import java.util.Set;

import org.openqa.selenium.By;
import org.openqa.selenium.Cookie;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.firefox.FirefoxDriver;
import org.openqa.selenium.firefox.FirefoxProfile;
import org.openqa.selenium.interactions.Actions;


public class TestCookie {
	public static void main(String args[]){
		FirefoxProfile profile = new FirefoxProfile();
//		profile.addAdditionalPreference("general.useragent.override", "some UA string");
		WebDriver driver = new FirefoxDriver(profile);
		
		driver.get("http://www.example.com");

		Cookie cookie = new Cookie("key", "value");
		driver.manage().addCookie(cookie);

		Set<Cookie> allCookies = driver.manage().getCookies();
		for (Cookie loadedCookie : allCookies) {
		    System.out.println(String.format("%s -> %s", loadedCookie.getName(), loadedCookie.getValue()));
		}

		driver.manage().deleteCookieNamed("CookieName");
		driver.manage().deleteAllCookies();
		
//		drag and drop
		WebElement source = driver.findElement(By.name("source"));
		WebElement target = driver.findElement(By.name("target"));
		
		(new Actions(driver)).dragAndDrop(source, target).perform();
	}
}
